package gdut.stream.middle;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class SortedTest {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Student student = new Student(i, "student" + i);
            students.add(student);
        }
        Stream<Student> studentStream = students.stream();
        studentStream
                .sorted((o1, o2) -> o2.getAge() - o1.getAge())
                .forEach(student -> System.out.println(student));
    }
}
